<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="<c:url value='../static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<!-- validate -->
<link rel="stylesheet"
	href="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.css'/>" />
<script type="text/javascript"
	src="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.js'/>"></script>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<title>商家店铺绑定</title>
</head>
<body>
	<div class="col-lg-12">
		<div id="message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>用户账号绑定</h4>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal" id="userForm" action="#">
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">用户生帐ID&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<a style="text-decoration: underline;"
											href="${path }/user/businessUserDetail?id=${data.businessUserId}">${data.businessUserId}</a>
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">店铺名称&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										${data.storeName}</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">平台类型&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<c:choose>
											<c:when test="${data.platformId==1}">
												淘宝/天猫
											</c:when>
											<c:otherwise>
												京东
											</c:otherwise>
										</c:choose>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">校验码&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										${data.securityCode}</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">校验产品链接&nbsp;:</label>

									<div class="col-sm-7" style="padding-top: 10px;">
										<c:if test="${!empty data.productLinks }">
											<a style="text-decoration: underline;"
												href="${data.productLinks}" target="_Blank">点击跳转</a>
										</c:if>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div class="panel panel-default bk-bg-white">
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form id="form2" action="#" method="GET" class="form-horizontal">
							<input type="hidden" name="id" id="id"
								value="${audit.auditApplicationId}"> <input
								type="hidden" name="auditStatus" id="auditStatus" value="1">
							<c:if test="${audit.auditStatus!=1 }">
								<div class="row">
									<div class="form-group col-sm-12">
										<label class="control-label">审核申请状态:</label>${audit.auditStatus==2?"通过":"未通过" }
									</div>
								</div>
							</c:if>
							<div class="row">
								<div class="form-group col-sm-12">
									<label class="control-label">审核员意见</label>
									<textarea id="auditOpinion" class="form-control"
										name="auditOpinion" data-plugin-markdown-editor rows="10"
										${audit.auditStatus!=1?'disabled="disabled"':'' }>${audit.auditOpinion }</textarea>
								</div>
							</div>
							<input type="hidden" id="access_type">
							<!-- panel-body -->
						</form>
					</div>
				</div>
			</div>
		</div>

		<div class="form-group" style="text-align: center;">
			<c:if test="${audit.auditStatus==1 }">
				<button type="button" id="unaccess" class="btn btn-default btn-sm"
					style="width: 150px">驳 回</button>
				<button type="button" id="access" class="btn btn-warning btn-sm"
					style="width: 150px">通 过</button>
			</c:if>
			<button type="button" id="back" class="btn btn-default btn-sm"
				style="width: 150px">返 回</button>
		</div>
	</div>
	<script type="text/javascript">
		$(function($) {
			//驳回
			$('#unaccess').click(function() {
				$('#access_type').val(3);
				$('#form2').bootstrapValidator('validate');
			});

			//通过
			$('#access').click(function() {
				$('#access_type').val(2);
				$('#form2').bootstrapValidator('validate');
			});

			//返回
			$('#back').click(function() {
				window.location.href = path + "/audit/list";
			});

			$('#form2').bootstrapValidator({
				message : '这个值未通过验证',
				feedbackIcons : {
					valid : 'glyphicon glyphicon-ok',
					invalid : 'glyphicon glyphicon-remove',
					validating : 'glyphicon glyphicon-refresh'
				},
				fields : {
					auditOpinion : {
						validators : {
							stringLength : {
								max : 200,
								message : '审核员意见长度最大200个字'
							}
						}
					}
				}
			}).on('success.form.bv', function(e) {
				var access_type = $('#access_type').val();
				var auditOpinion = $("#auditOpinion").val();
				if (access_type == 3 && !auditOpinion) {
					showmessage("请填写审核意见！");
					return;
				}
				update(access_type, auditOpinion);
			});

		});

		//执行更新
		function update(type, auditOpinion) {
			$.ajax({
				type : "post",
				url : path + "/audit/edit",
				cache : false,
				data : {
					id : $('#id').val(),
					auditStatus : type,
					auditOpinion : auditOpinion,
					_t : new Date().getTime()
				},
				dataType : "json",
				success : function(data) {
					if (data.success) {
						showmessage("提交成功", function() {
							window.location.href = path + "/audit/list";
						});
					} else {
						showmessage("提交失败");
					}
				}
			});
		}

		//显示消息
		function showmessage(msg, callback) {
			$('#message').ucMessage({
				msg : msg,
				callback : callback
			});
		}
	</script>
</body>
</html>